// OUTDOOR SECTION SCRIPT
//    Section: X = 0, Y = 2

// This is the special encounter script for this town.
// The states INIT_STATE and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

beginoutdoorscript;

variables;

short i,j,k,r1,choice;

body;

beginstate INIT_STATE;
	set_state_continue(22);
break;

beginstate START_STATE;
	set_state_continue(22);
break;

beginstate 10;
	if (character_in_party(1702) > 3)
		set_state_continue(12);
	else set_state_continue(11);
break;

beginstate 11;
	message_dialog("You look down from the precipice. It's quite an awe-inspiring sight. Flights of sea-birds sweep by, and the strong west wind, filled with a slightly salty flavor, is dimmed by the roar of the waters.",
	  "As pleasant as it might be to linger here, you have errands to accomplish. After a few minutes, you walk back.");
break;

beginstate 12;
	message_dialog("You look down from the precipice. It's quite an awe-inspiring sight. Flights of sea-birds sweep by, and the strong west wind, filled with a slightly salty flavor, is dimmed by the roar of the waters.",
	  "You suddenly become aware of a steady stream of rocks assailing the gulls. You turn to Fernow. She drops the rocks, shrugs, and starts walking down.");
break;

beginstate 13;
	reset_dialog();
	add_dialog_str(0,"You come upon a large farmhouse. Wandering about a bit, you are drawn to a shop set up just outside selling farming utilities.",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Buy.");
	choice = run_dialog(1);
	if (choice == 2)
		begin_shop_mode("Farming Utilities","You find a few basic items for sale.",6,3,-1);
break;

beginstate 15;
	if (get_flag(100,0) >= 7)
	outdoor_enc_result(1);
break;

beginstate 17;
	if (get_flag(299,1) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"Soldiers of the Wolf, pursuing some herdsmen, have cornered them. Paying no attention to your presence, they advance. The herdsmen are clearly in a panic. Do you help the herdsmen, or leave them be?",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Attack.");
	choice = run_dialog(1);
	set_flag(299,1,250);
	if (choice == 1)
		set_state_continue(21);
	if (choice == 2)
		set_state_continue(18);
break;

beginstate 18;
	message_dialog("The soldiers are surprised at your intervention. Seeing you as rebels, they attack without mercy.","");
	create_out_spec_enc(0);
break;

beginstate 19;
	reset_dialog();
	add_dialog_str(0,"The herdsmen thank you profusely for your aid. Shoving you a large sack of food, they hurry away without explanations.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	reward_give(4);
	reward_give(5);
	reward_give(6);
	reward_give(7);
	reward_give(8);
	set_state_continue(22);	
break;

beginstate 21;
	message_dialog("You quietly move away. The herdsmen are rounded up, bound, and escorted southward towards the city. Wanted criminals, probably.","");
	set_state_continue(22);
break;

beginstate 22;
	if (get_flag(299,1) == 250)
	set_terrain(32,8,0);
break;

